/**
 * Methods used by main algorithms for SNF.
 */

#define RIDX(i, j, n) ((i)*(n)+(j))

namespace utils
{
  /*
   * Transforms an upper triangular band matrix into a diagonal matrix.
   */
  int bandToDiag(int *A, unsigned int n);

  /*
   * Transforms a diagonal matrix into SNF.
   */
  int diagToSmith(int *A, unsigned int n);

  /*
   * Unimodular operation to replace the first element with the gcd of itself and another in the row.
   */
  int gcdRow(int *A, int row, int colI, int colJ, unsigned int n);

  /*
   * Unimodular operation to replace the first element with the gcd of itself and another in the col.
   */
  int gcdCol(int *A, int col, int rowI, int rowJ, unsigned int n);

  /*
   * Prints the matrix.
   */
  int printMatrix(int *A, unsigned int n);

  /*
   * Randomizes the elements of a matrix.
   */
  int randomizeMatrix(int *A, unsigned int n);
}
